import request from '@/router/axios';

const vformAPI = {
    saveVForm: '/api/app/worksheet/info/save',
    getVFormData: '/api/app/worksheet/info/get',
    updateVForm: '/api/app/worksheet/info/update',
    addRow: '/api/app/worksheet/rows/save'
}


// export function saveForm (params) {
//     return request({
//       url: vformAPI.saveVForm,
//       method: 'post',
//       data: params
//     })
//   }

  export function getFormData (params) {
    return new Promise((resolve, reject) => {
      request({
        url: vformAPI.getVFormData,
        method: 'get',
        params: params
      }).then(res => {
        if(res.status === 200 && res.data.code === 200){
          resolve(res.data.data)
        } else {
          reject(false)
        }
      })
    })
  }

  export function updateVForm (params) {
    return new Promise((resolve, reject) => {
      request({
        url: vformAPI.updateVForm,
        method: 'post',
        data: params
      }).then(res => {
        if(res.status === 200 && res.data.code === 200){
          resolve(true)
        } else {
          reject(false)
        }
      })
    })
  }

  export function addRow (params) {
    return new Promise((resolve, reject) => {
      request({
        url: vformAPI.addRow,
        method: 'post',
        data: params
      }).then(res => {
        if(res.status === 200 && res.data.code === 200){
          resolve(true)
        } else {
          reject(false)
        }
      })
    })
  }